/*     */ package com.feeyin.radar.sys.service.impl;
/*     */ 
/*     */ import com.feeyin.radar.sys.dao.FunctionTreeDAO;
/*     */ import com.feeyin.radar.sys.model.FunctionTree;
/*     */ import com.feeyin.radar.sys.service.FunctionTreeService;
/*     */ import java.util.List;
/*     */ 
/*     */ public class FunctionTreeServiceImpl
/*     */   implements FunctionTreeService
/*     */ {
/*     */   private FunctionTreeDAO functionTreeDAO;
/*     */ 
/*     */   public FunctionTreeDAO getFunctionTreeDAO()
/*     */   {
/*  20 */     return this.functionTreeDAO;
/*     */   }
/*     */ 
/*     */   public void setFunctionTreeDAO(FunctionTreeDAO functionTreeDAO) {
/*  24 */     this.functionTreeDAO = functionTreeDAO;
/*     */   }
/*     */ 
/*     */   public List getFunctions() {
/*  28 */     return this.functionTreeDAO.getFunctions();
/*     */   }
/*     */ 
/*     */   public List getFunctionsByActivity() {
/*  32 */     return this.functionTreeDAO.getFunctionsByActivity();
/*     */   }
/*     */ 
/*     */   public List getViewFunctions() {
/*  36 */     return this.functionTreeDAO.getViewFunctions();
/*     */   }
/*     */ 
/*     */   public List getFunctionsByUserId(Integer userId) {
/*  40 */     return this.functionTreeDAO.getFunctionsByUserId(userId);
/*     */   }
/*     */ 
/*     */   public FunctionTree getFunction(Integer id) {
/*  44 */     String str = "";
/*  45 */     FunctionTree function = new FunctionTree();
/*  46 */     function = this.functionTreeDAO.getFunction(id);
/*  47 */     if ((function != null) && (function.getFunctionOrder() != null) && 
/*  48 */       (function.getParentId().intValue() != 0)) {
/*  49 */       str = function.getFunctionOrder()+"";
/*  50 */       str = str.replaceFirst(function.getParentId().toString(), "");
/*  51 */       if ((str != null) && (!"".equals(str))) {
/*  52 */         function.setFunctionOrder(Integer.valueOf(Integer.parseInt(str)));
/*     */       }
/*     */ 
/*  55 */       FunctionTree func = new FunctionTree();
/*  56 */       func = this.functionTreeDAO.getFunction(function.getParentId());
/*  57 */       if (func != null) {
/*  58 */         function.setParentName(func.getFunctionName());
/*     */       }
/*     */     }
/*  61 */     return function;
/*     */   }
/*     */ 
/*     */   public FunctionTree getFunctionByNameParentId(String functionName, Integer parentId) {
/*  65 */     return this.functionTreeDAO.getFunctionByNameParentId(functionName, parentId);
/*     */   }
/*     */ 
/*     */   public boolean isRepeatUpdateFunction(FunctionTree function) {
/*  69 */     if (function == null) return false;
/*     */ 
/*  71 */     FunctionTree oldFunction = new FunctionTree();
/*  72 */     oldFunction = this.functionTreeDAO.getFunction(function.getId());
/*  73 */     if (oldFunction == null) return false;
/*     */ 
/*  75 */     if (!function.getFunctionName().equals(oldFunction.getFunctionName())) {
/*  76 */       FunctionTree func = new FunctionTree();
/*  77 */       func = this.functionTreeDAO.getFunctionByNameParentId(function.getFunctionName(), function.getParentId());
/*  78 */       if (func != null) return true;
/*     */     }
/*  80 */     return false;
/*     */   }
/*     */ 
/*     */   public boolean insertFunction(FunctionTree functionTree) {
/*  84 */     boolean result1 = false;
/*  85 */     boolean result2 = false;
/*     */ 
/*  87 */     result1 = this.functionTreeDAO.insertFunction(functionTree);
/*     */ 
/*  89 */     FunctionTree func = new FunctionTree();
/*  90 */     func = this.functionTreeDAO.getFunctionByNameParentId(functionTree.getFunctionName(), functionTree.getParentId());
/*  91 */     if (func != null) {
/*  92 */       if (functionTree.getParentId().intValue() == 0)
/*  93 */         functionTree.setFunctionOrder(func.getId());
/*     */       else {
/*  95 */         functionTree.setFunctionOrder(Integer.valueOf(Integer.parseInt(func.getParentId() + functionTree.getFunctionOrder()+"")));
/*     */       }
/*     */     }
/*  98 */     functionTree.setId(func.getId());
/*  99 */     result2 = this.functionTreeDAO.updateFunction(functionTree);
/*     */ 
/* 101 */     return (result1) && (result2);
/*     */   }
/*     */ 
/*     */   public boolean updateFunction(FunctionTree functionTree)
/*     */   {
/* 106 */     if (functionTree != null) {
/* 107 */       if (functionTree.getParentId().intValue() == 0)
/* 108 */         functionTree.setFunctionOrder(functionTree.getId());
/*     */       else {
/* 110 */         functionTree.setFunctionOrder(Integer.valueOf(Integer.parseInt(functionTree.getParentId() + functionTree.getFunctionOrder()+"")));
/*     */       }
/*     */     }
/*     */ 
/* 114 */     return this.functionTreeDAO.updateFunction(functionTree);
/*     */   }
/*     */ 
/*     */   public boolean updateFunctionByFunctionNameEn(String functionNameEn, String status) {
/* 118 */     return this.functionTreeDAO.updateFunctionByFunctionNameEn(functionNameEn, status);
/*     */   }
/*     */ 
/*     */   public boolean updateFunctionByFunctionCode(String functionCode, String status)
/*     */   {
/* 123 */     return this.functionTreeDAO.updateFunctionByFunctionCode(functionCode, status);
/*     */   }
/*     */ 
/*     */   public boolean deleteFunction(Integer id, Integer parentId) {
/* 127 */     boolean result = false;
/* 128 */     if (parentId.intValue() == 0) {
/* 129 */       boolean result2 = false;
/* 130 */       result2 = this.functionTreeDAO.deleteFunctionByParentId(id);
/* 131 */       result = this.functionTreeDAO.deleteFunction(id);
/* 132 */       if ((result2) && (result)) return true; 
/*     */     }
/*     */     else {
/* 134 */       result = this.functionTreeDAO.deleteFunction(id);
/*     */     }
/* 136 */     return result;
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.service.impl.FunctionTreeServiceImpl
 * JD-Core Version:    0.6.0
 */